<template>
  <view class="container">
    <view v-for="(item, id) in leaveList" :key="item.id" class="leave-item">
      <view class="leave-info" >
        <view class="info-item">教师姓名：{{ item.teacherName }}</view>
        <view class="info-item">所在部门：{{ item.departmentId }}</view>
        <!-- <view class="info-item" v-html="'请假说明：'+item.leaveDetailes"></view> -->
        <view class="info-item">出勤时间：{{ item.attendanceTime }}</view>
        <view class="info-item">在岗时长：{{ item.dutyTime }}</view>
        <view class="info-item">加班时长：{{ item.overtimeHours }}</view>
        <view class="info-item">异常备注：{{ item.exceptionRemarks }}</view>
        <view class="info-item">用户序号：{{ item.userId }}</view>
        <view class="info-item">部门编号：{{ item.deptId }}</view>
        <view class="info-item">登录名称：{{ item.userName }}</view>
		<view class="info-item">用户邮箱：{{ item.email }}</view>
		<view class="info-item">手机号码：{{ item.phonenumber }}</view>
        <view class="info-item">用户性别：{{ item.sex === '0' ? '男' : (item.sex === '1' ? '女' : '未知') }}</view>
      </view>
    </view>
	<uni-fab ref="fab" horizontal="right" vertical="bottom" direction="horizontal" @fabClick="toAddAskfor"/>
  </view>
</template>

<script>
export default {
  data() {
    return {
      leaveList: []
    };
  },
  mounted() {
    this.fetchLeaveList();
  },
  methods: {
	  toAddAskfor(){
	  	uni.navigateTo({
	  		url:'/pages/askfor/addaskfor'
	  	})
	  }, 
	 fetchLeaveList(){
		uni.request({
			 url: 'https://www.gzzyue.com/prod-api/system/attendanceView/list',
			method: 'GET',
			header: {
				'Authorization': uni.getStorageSync("token") //自定义请求头信息
			},
			success: (res) => {
				console.log('res:', res);
				if (res.statusCode == 200) {
					if (res.data.code == 200) {
						
						 this.leaveList = res.data.rows;
						
					} else if (res.data.code == 500) {
						uni.$u.toast(res.data.msg)
					} else {
						uni.$u.toast('系统服务异常，请联系管理员！')
					}
				} else {
					uni.$u.toast('系统服务异常，请联系管理员！')
				}
			},
			fail: (errors) => {
				console.log('errors:', errors);
				uni.$u.toast('服务器错误，请联系管理员！')
			},
		});
	},
  }
};
</script>

<style scoped>
.container {
  padding: 20rpx;
  background-color: #f2f2f2;
}


.leave-item {
  margin-bottom: 20rpx;
  border: none;
  box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.1);
  background-color: #fff;
  border-radius: 5rpx;
  padding: 10rpx;
}


.info-item {
  margin-bottom: 8rpx;
}
.uni-fab {
  position: fixed;
  right: 20rpx;
  bottom: 20rpx;
}
.uni-fab .uni-icons {
  color: #fff;
}

.uni-fab {
  background-color: #007aff;
}

</style>
